package cn.wolfcode.p2p.mgrsite.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.wolfcode.p2p.base.exception.DisplayableException;
import cn.wolfcode.p2p.base.util.JSONResult;
import cn.wolfcode.p2p.business.domain.PlatformBankInfo;
import cn.wolfcode.p2p.business.service.IPlatformBankInfoService;

/**
 * 平台账户信息控制器
 * 
 * @author wolfcode
 *
 */
@Controller
public class PlatformBankInfoController {

	@Autowired
	private IPlatformBankInfoService service;

	/**
	 * 添加或修改
	 */
	@RequestMapping("companyBank_update")
	@ResponseBody
	public JSONResult saveOrUpdate(PlatformBankInfo pbi) {
		JSONResult result = new JSONResult();
		try {
			this.service.saveOrUpdate(pbi);
		} catch (DisplayableException ex) {
			result = new JSONResult(false, ex.getMessage());
		} catch (Exception e) {
			// 把错误信息记录到服务器中日志文件中,方便排查问题.
			result = new JSONResult(false, "系统异常,请联系管理员!");
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 列表
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping("companyBank_list")
	public String bankList(Model model) {
		model.addAttribute("list", this.service.list());
		return "platformbankinfo/list";
	}

}
